﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace ComForm
{
    public partial class FormShowImageTips : Form
    {
        private Image TipImage = null;

        private int CountDownSecond = 30;

        public FormShowImageTips(Image image, int sec = 30)
        {
            TipImage = image;
            CountDownSecond = sec;
            InitializeComponent();
        }

        private void FormShowImageTips_Load(object sender, EventArgs e)
        {
            timer1.Enabled = true;
            if(TipImage != null)
            {
                pictureBoxTip.Size = TipImage.Size;
                pictureBoxTip.Image = TipImage;
                pictureBoxTip.Left = (this.Width - TipImage.Width) / 2;
            }
        }

        private void buttonOK_Click(object sender, EventArgs e)
        {
            timer1.Enabled = false;
            this.Close();
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            if (CountDownSecond >= 0)
            {
                labelSec.Text = CountDownSecond.ToString();
                CountDownSecond--;
            }
            else
            {
                this.Close();
            }
        }


    }
}
